package com.chuanyang.driverh.mainmy.adapter;


import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.chuanyang.driverh.R;
import com.chuanyang.driverh.base.BaseListAdapter;
import com.chuanyang.driverh.responseresult.CommentData;
import com.chuanyang.driverh.utils.BitmapUtil;

import java.util.List;

/**
 * 评论的适配器
 */
public class CarOwnerCommentsdapter extends BaseListAdapter<CommentData.DataBean> {
    private final List<CommentData.DataBean> objects;
    private Context context;
    private ViewHolder viewHolder;

    public CarOwnerCommentsdapter(Context context, List<CommentData.DataBean> objects) {
        super(context, objects);
        this.context=context;
        this.objects=objects;
    }

    @Override
    public View getZkView(int position, View convertView, ViewGroup parent) {
        if (convertView==null)
        {
            convertView= View.inflate(context, R.layout.my_item_comment,null);
            viewHolder = new ViewHolder();
            viewHolder.iv_comment_icon= (ImageView) convertView.findViewById(R.id.iv_comment_icon);
            viewHolder.tv_comment_name= (TextView) convertView.findViewById(R.id.tv_comment_name);
            viewHolder.tv_comment_time= (TextView) convertView.findViewById(R.id.tv_comment_time);
            viewHolder.tv_comment_content= (TextView) convertView.findViewById(R.id.tv_comment_content);
            convertView.setTag(viewHolder);
        }
        else {
            viewHolder= (ViewHolder) convertView.getTag();
        }
        CommentData.DataBean  bean=getItem(position);
         //设置数据后期写
        BitmapUtil.showImgForNetPath(bean.getUserImage(),viewHolder.iv_comment_icon);
        viewHolder.tv_comment_name.setText(bean.getUserName());
        viewHolder.tv_comment_time.setText(bean.getCreateTime());
        viewHolder.tv_comment_content.setText(bean.getEDetail());


        return convertView;
    }

    class ViewHolder
    {
        ImageView iv_comment_icon;
        TextView tv_comment_name;
        TextView tv_comment_time;
        TextView tv_comment_content;

    }
}
